

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" href="/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="沧海横流，尽显英雄本色；激浊扬清，正是猛士当时">
  <meta name="author" content="closer">
  <meta name="keywords" content="">
  
  <title>树莓派配置 - closer的自留地</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10.6.0/styles/androidstudio.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
  



<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"blog.zsaa.top","root":"/","version":"1.8.10","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"always","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":true,"baidu":"608f2baddd361128381ad2bf9377bf89","google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":"YzLqNtMw1YEwwACli1FUsIUM-gzGzoHsz","app_key":"HLUt5izfTvTcbEbOrA59W92a","server_url":"https://yzlqntmw.lc-cn-n1-shared.com"}}};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.4.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>Hello</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/links/">
                <i class="iconfont icon-link-fill"></i>
                友链
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/img/default.jpg') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="树莓派配置">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2020-03-06 14:29" pubdate>
        2020年3月6日 下午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1.3k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      18
       分钟
    </span>
  

  
  
    
      <!-- LeanCloud 统计文章PV -->
      <span id="leancloud-page-views-container" class="post-meta" style="display: none">
        <i class="iconfont icon-eye" aria-hidden="true"></i>
        <span id="leancloud-page-views"></span> 次
      </span>
    
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">树莓派配置</h1>
            
              <p class="note note-info">
                
                  本文最后更新于：2020年8月9日 下午
                
              </p>
            
            <div class="markdown-body">
              <blockquote>
<p><a target="_blank" rel="noopener" href="https://gitee.com/openfans-community/Debian-Pi-Aarch64/blob/master/README_zh.md#3-2%E8%B4%A6%E6%88%B7%E5%8F%8A%E5%AF%86%E7%A0%81">64位系统Debian-Pi-Aarch64</a><br>集成了常用软件，配置简单。不需要换源，开箱即食。</p>
</blockquote>
<h2 id="零：-换源"><a href="#零：-换源" class="headerlink" title="零： 换源"></a>零： 换源</h2><p><a target="_blank" rel="noopener" href="https://mirrors.tuna.tsinghua.edu.cn/help/raspbian/">清华大学源使用帮助</a></p>
<figure class="highlight yml"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs yml"><span class="hljs-comment"># 编辑 `/etc/apt/sources.list` 文件，删除原文件所有内容，用以下内容取代：</span><br><span class="hljs-string">deb</span> <span class="hljs-string">http://mirrors.tuna.tsinghua.edu.cn/raspberry-pi-os/raspbian/</span> <span class="hljs-string">buster</span> <span class="hljs-string">main</span> <span class="hljs-string">non-free</span> <span class="hljs-string">contrib</span> <span class="hljs-string">rpi</span><br><span class="hljs-string">deb-src</span> <span class="hljs-string">http://mirrors.tuna.tsinghua.edu.cn/raspberry-pi-os/raspbian/</span> <span class="hljs-string">buster</span> <span class="hljs-string">main</span> <span class="hljs-string">non-free</span> <span class="hljs-string">contrib</span> <span class="hljs-string">rpi</span><br><br><span class="hljs-comment"># 编辑 `/etc/apt/sources.list.d/raspi.list` 文件，删除原文件所有内容，用以下内容取代：</span><br><span class="hljs-string">deb</span> <span class="hljs-string">http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/</span> <span class="hljs-string">buster</span> <span class="hljs-string">main</span> <span class="hljs-string">ui</span><br></code></pre></div></td></tr></table></figure>

<blockquote>
<p>注意：网址末尾的raspbian重复两次是必须的。因为 RPi OS 的仓库中除了APT软件源还包含其他代码。APT软件源不在仓库的根目录，而在raspbian/子目录下。<br>编辑镜像站后，请使用<code>sudo apt-get update</code>命令，更新软件源列表，同时检查您的编辑是否正确。</p>
</blockquote>
<h2 id="一-修改密码及时间"><a href="#一-修改密码及时间" class="headerlink" title="一: 修改密码及时间"></a>一: 修改密码及时间</h2><h3 id="1-1-开启SSH访问"><a href="#1-1-开启SSH访问" class="headerlink" title="1.1 开启SSH访问"></a>1.1 开启SSH访问</h3><p><code>sudo raspi-config</code></p>
<p>5 -&gt; P2 SSH -&gt; enable.</p>
<h3 id="1-2-设置su及pi密码"><a href="#1-2-设置su及pi密码" class="headerlink" title="1.2 设置su及pi密码"></a>1.2 设置su及pi密码</h3><figure class="highlight shell"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs shell">sudo passwd pi                   # 修改 Pi 密码  <br>sudo passwd root                 # 设置 root 密码<br>su root                          # 切换到 root 用户  <br>su pi                            # 切换到 pi 用户<br><br>sudo nano /etc/ssh/sshd_config<br><span class="hljs-meta">#</span><span class="bash"> 编辑/etc/ssh/sshd_config文件，找到<span class="hljs-comment">#PermitRootLogin ...一行修改为：</span></span><br>PermitRootLogin yes<br>PubkeyAuthentication yes<br></code></pre></div></td></tr></table></figure>

<h3 id="1-3-修改时间"><a href="#1-3-修改时间" class="headerlink" title="1.3 修改时间"></a>1.3 修改时间</h3><p>使用date 语句查看时间，如不正确，则：首先在终端中用下面的命令安装ntpdate工具</p>
<p><code>sudo apt install ntpdate</code></p>
<p>启用NTP</p>
<p><code>sudo timedatectl set-ntp true</code></p>
<p>继续使用date语句查看时间，如不正确，则：</p>
<p><code>sudo dpkg-reconfigure tzdata</code></p>
<p>修改时区为Asia Shanghai，继续使用date语句查看时间并确认正确</p>
<h3 id="1-4-配置ssh"><a href="#1-4-配置ssh" class="headerlink" title="1.4 配置ssh"></a>1.4 配置ssh</h3><figure class="highlight shell"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs shell">ssh-keygen -t rsa<br><span class="hljs-meta">#</span><span class="bash"> 连续回车</span><br><br>sudo cd ~/.ssh<br>sudo touch authorized_keys<br>sudo chmod 600 ~/.ssh/authorized_keys<br>sudo nano ~/.ssh/authorized_keys<br><span class="hljs-meta">#</span><span class="bash"> 将PC公匙复制进去，保存</span><br>service sshd restart<br><span class="hljs-meta"></span><br><span class="hljs-meta">#</span><span class="bash"> 配置本地ssh无密码登录远程主机</span><br>ssh-copy-id username@remote-server<br><span class="hljs-meta">#</span><span class="bash"> 输入远程主机密码即可</span><br></code></pre></div></td></tr></table></figure>

<h2 id="二-中文环境"><a href="#二-中文环境" class="headerlink" title="二: 中文环境"></a>二: 中文环境</h2><h2 id="2-1-安装中文输入法"><a href="#2-1-安装中文输入法" class="headerlink" title="2.1 安装中文输入法"></a>2.1 安装中文输入法</h2><p><code>sudo apt install scim-pinyin</code></p>
<h2 id="2-2-配置中文环境"><a href="#2-2-配置中文环境" class="headerlink" title="2.2 配置中文环境"></a>2.2 配置中文环境</h2><p><code>sudo raspi-config</code></p>
<p>按4 -&gt; 1<br>在Configuring locales窗口中，找到zh_CN.UTF-8 UTF-8</p>
<p>空格选中，并在确认后再次选择zh_CN.UTF-8</p>
<h3 id="2-3-安装中文字库"><a href="#2-3-安装中文字库" class="headerlink" title="2.3 安装中文字库"></a>2.3 安装中文字库</h3><p><code>sudo apt install ttf-wqy-zenhei</code></p>
<p><code>reboot</code></p>
<h2 id="三-基本设置及软件"><a href="#三-基本设置及软件" class="headerlink" title="三: 基本设置及软件"></a>三: 基本设置及软件</h2><h3 id="3-1-设置为固定ip访问"><a href="#3-1-设置为固定ip访问" class="headerlink" title="3.1 设置为固定ip访问"></a>3.1 设置为固定ip访问</h3><p>先进入配置文件<br><code>sudo nano /etc/dhcpcd.conf</code></p>
<figure class="highlight shell"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> 有线设置</span><br>interface eth0<br><span class="hljs-meta">#</span><span class="bash"> 默认网关，即路由器ip</span><br>static routers=192.168.2.8<br><span class="hljs-meta">#</span><span class="bash"> DNS</span><br>static domain_name_servers=192.168.2.1 8.8.8.8<br>static ip_address=192.168.2.4/24<br><span class="hljs-meta"></span><br><span class="hljs-meta">#</span><span class="bash"> 无线设置</span><br>interface wlan0<br><span class="hljs-meta">#</span><span class="bash"> 默认网关，即路由器ip</span><br>static routers=192.168.2.8<br><span class="hljs-meta">#</span><span class="bash"> DNS</span><br>static domain_name_servers=192.168.2.1 8.8.8.8<br>static ip_address=192.168.2.4/24<br></code></pre></div></td></tr></table></figure>

<p>如果是64位系统，设置如下文件：<br>修改 /boot/interfaces 文件</p>
<figure class="highlight shell"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> interfaces(5) file used by ifup(8) and ifdown(8)</span><br><span class="hljs-meta">#</span><span class="bash"> Include files from /etc/network/interfaces.d:</span><br>source-directory /etc/network/interfaces.d<br><span class="hljs-meta">#</span><span class="bash"><span class="hljs-comment"># Used dhcp ip address set eth0 inet to dhcp,</span></span><br><span class="hljs-meta">#</span><span class="bash"><span class="hljs-comment"># or used static ip address set eth0 to static</span></span><br><span class="hljs-meta">#</span><span class="bash"><span class="hljs-comment"># and change other ip settings.</span></span><br><span class="hljs-meta">#</span><span class="bash"><span class="hljs-comment"># If you wanna let settings to take effect,</span></span><br><span class="hljs-meta">#</span><span class="bash"><span class="hljs-comment"># uncomment symbol in front.</span></span><br><br>auto eth0<br>allow-hotplug eth0<br><span class="hljs-meta"></span><br><span class="hljs-meta">#</span><span class="bash">iface eth0 inet dhcp</span><br>iface eth0 inet static<br>address 192.168.2.4<br>netmask 255.255.255.0<br>gateway 192.168.2.8<br>dns-nameservers 192.168.2.8 8.8.8.8<br></code></pre></div></td></tr></table></figure>

<h3 id="3-2-添加树莓派开机启动命令，如花生壳"><a href="#3-2-添加树莓派开机启动命令，如花生壳" class="headerlink" title="3.2 添加树莓派开机启动命令，如花生壳"></a>3.2 添加树莓派开机启动命令，如花生壳</h3><figure class="highlight sh"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs SH">sudo nano /etc/rc.local<br><br><span class="hljs-comment"># 在exit 0 的上一行输入命令。比如花生壳是用phddns.start启动，再这里加入后花生壳就会自动启动了。</span><br>sudo phddns.start<br></code></pre></div></td></tr></table></figure>

<h3 id="3-3-安装mysql-server"><a href="#3-3-安装mysql-server" class="headerlink" title="3.3 安装mysql-server"></a>3.3 安装mysql-server</h3><p>因mysql-server被收购，故安装mariadb-server，MariaDB是MySQL源代码的一个分支，一样用。</p>
<figure class="highlight sh"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs sh">sudo apt install mariadb-server -y<br><span class="hljs-comment"># 通过命令连接到MariaDB</span><br>sudo mysql<br></code></pre></div></td></tr></table></figure>

<p>接下来配置mysql密码访问。</p>
<figure class="highlight sql"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs SQL">use mysql;<br>UPDATE <span class="hljs-keyword">user</span> <span class="hljs-keyword">SET</span> password<span class="hljs-operator">=</span>password(<span class="hljs-string">&#x27;改为你的密码,比如root&#x27;</span>) <span class="hljs-keyword">WHERE</span> <span class="hljs-keyword">user</span><span class="hljs-operator">=</span><span class="hljs-string">&#x27;root&#x27;</span>;<br>UPDATE <span class="hljs-keyword">user</span> <span class="hljs-keyword">SET</span> plugin<span class="hljs-operator">=</span><span class="hljs-string">&#x27;mysql_native_password&#x27;</span> <span class="hljs-keyword">WHERE</span> <span class="hljs-keyword">user</span> <span class="hljs-operator">=</span> <span class="hljs-string">&#x27;root&#x27;</span>;<br>flush privileges;<br>exit<br></code></pre></div></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs sh"><span class="hljs-comment"># 重启服务</span><br>sudo systemctl restart mariadb<br><span class="hljs-comment"># 密码登录mysql</span><br>mysql -u root -p<br></code></pre></div></td></tr></table></figure>

<p>下面配置MariaDB可远程连接</p>
<figure class="highlight sh"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs sh"><span class="hljs-comment"># MariaDB默认只监听了127.0.0.1这个IP地址，是无法从外部连接到树莓派上MariaDB。故修改配置</span><br>sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf<br><span class="hljs-comment"># 注释其中的127.0.0.1所在一行，示例如下：</span><br><span class="hljs-comment"># bind-address            = 127.0.0.1</span><br><span class="hljs-comment"># 这样MariaDB就监听了所有的IP。</span><br></code></pre></div></td></tr></table></figure>

<figure class="highlight sql"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs sql"><span class="hljs-comment">--授权用户能够连接MariaDB Server</span><br>mysql <span class="hljs-operator">-</span>u root <span class="hljs-operator">-</span>p<br><span class="hljs-keyword">GRANT</span> <span class="hljs-keyword">ALL</span> PRIVILEGES <span class="hljs-keyword">ON</span> <span class="hljs-operator">*</span>.<span class="hljs-operator">*</span> <span class="hljs-keyword">TO</span> <span class="hljs-string">&#x27;root&#x27;</span>@<span class="hljs-string">&#x27;%&#x27;</span> IDENTIFIED <span class="hljs-keyword">BY</span> <span class="hljs-string">&#x27;改为你的密码，如root&#x27;</span>;<br><span class="hljs-comment">--更新权限</span><br>FLUSH PRIVILEGES;<br></code></pre></div></td></tr></table></figure>

<h3 id="3-4-安装、配置和加速docker"><a href="#3-4-安装、配置和加速docker" class="headerlink" title="3.4 安装、配置和加速docker"></a>3.4 安装、配置和加速docker</h3><p><a target="_blank" rel="noopener" href="https://shumeipai.nxez.com/2019/05/20/how-to-install-docker-on-your-raspberry-pi.html">安装教程</a></p>
<figure class="highlight shell"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> 脚本安装</span><br>sudo curl -fsSL https://get.docker.com -o get-docker.sh | sh<br><span class="hljs-meta"></span><br><span class="hljs-meta">#</span><span class="bash"> 查看版本</span><br>docker -v<br><span class="hljs-meta"></span><br><span class="hljs-meta">#</span><span class="bash"> 配置docker镜像加速</span><br><span class="hljs-meta">#</span><span class="bash"> 阿里云镜像获取地址：https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors，登陆后，左侧菜单选中镜像加速器就可以看到你的专属地址了</span><br><span class="hljs-meta">#</span><span class="bash"> 按照页面的操作文档配置加速</span><br>sudo mkdir -p /etc/docker<br><br>sudo tee /etc/docker/daemon.json &lt;&lt;-&#x27;EOF&#x27;<br>&#123;<br>  &quot;registry-mirrors&quot;: [&quot;https://改为你的加速器地址.mirror.aliyuncs.com&quot;]<br>&#125;<br>EOF<br><br>sudo systemctl daemon-reload<br><br>sudo systemctl restart docker<br><span class="hljs-meta"></span><br><span class="hljs-meta">#</span><span class="bash"> 下载 Docker 图形化界面 portainer</span><br>sudo docker pull portainer/portainer<br><span class="hljs-meta"></span><br><span class="hljs-meta">#</span><span class="bash"> 创建 portainer 容器</span><br>sudo docker volume create portainer_data<br><span class="hljs-meta"></span><br><span class="hljs-meta">#</span><span class="bash"> 运行 portainer</span><br>sudo docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer<br><span class="hljs-meta"></span><br><span class="hljs-meta">#</span><span class="bash"> 输入树莓派ip:9000登录管理界面</span><br></code></pre></div></td></tr></table></figure>

<h3 id="3-5-其他常用软件"><a href="#3-5-其他常用软件" class="headerlink" title="3.5 其他常用软件"></a>3.5 其他常用软件</h3><p><code>sudo apt install git vim -y</code><br><code>sudo apt install tar gzip zip unzip bzip2 xz-utils -y</code></p>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/categories/Linux/">Linux</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/Linux/">Linux</a>
                    
                      <a class="hover-with-bg" href="/tags/%E6%A0%91%E8%8E%93%E6%B4%BE/">树莓派</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2020/03/07/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/Python/python%E5%AD%A6%E4%B9%A0%E4%B9%8B%E8%B7%AF%20%E4%BA%8C%EF%BC%9Acookie/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">python学习之路 二：cookie</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2020/02/23/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/SQL/%E5%85%B3%E7%B3%BB%E5%9E%8B%E6%95%B0%E6%8D%AE%E5%BA%93MySQL/">
                        <span class="hidden-mobile">关系数据库MySQL入门</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
              <!-- Comments -->
              <article class="comments" id="comments" lazyload>
                
                  
                
                
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js', function () {
        new Valine({
          el: "#valine",
          app_id: "YzLqNtMw1YEwwACli1FUsIUM-gzGzoHsz",
          app_key: "HLUt5izfTvTcbEbOrA59W92a",
          placeholder: "畅所欲言...",
          path: window.location.pathname,
          avatar: "robohash",
          meta: ["nick","mail","link"],
          pageSize: "10",
          lang: "zh-CN",
          highlight: true,
          recordIP: false,
          serverURLs: "",
        });
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


              </article>
            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->

  <div class="col-lg-7 mx-auto nopadding-x-md">
    <div class="container custom post-custom mx-auto">
      <img src="https://closer_laps.coding.net/p/picture/d/picture/git/raw/master/pay/pay.png" srcset="/img/loading.gif" lazyload class="rounded mx-auto d-block mt-3" style="width:355.4px; height:200px;">
    </div>
  </div>


    

    
      <a id="scroll-top-button" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  
  <div class="statistics">
    
    

    
      
        <!-- LeanCloud 统计PV -->
        <span id="leancloud-site-pv-container" style="display: none">
            总访问量 
            <span id="leancloud-site-pv"></span>
             次
          </span>
      
      
        <!-- LeanCloud 统计UV -->
        <span id="leancloud-site-uv-container" style="display: none">
            总访客数 
            <span id="leancloud-site-uv"></span>
             人
          </span>
      

    
  </div>


  
  <!-- 备案信息 -->
  <div class="beian">
    <span>
      <a href="http://beian.miit.gov.cn/" target="_blank" rel="nofollow noopener">
        苏ICP备20032307号
      </a>
    </span>
    
      
        <span>
          <a
            href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=32020602001023"
            rel="nofollow noopener"
            class="beian-police"
            target="_blank"
          >
            
              <span style="visibility: hidden; width: 0">|</span>
              <img src="/img/police_beian.png" srcset="/img/loading.gif" lazyload alt="police-icon"/>
            
            <span>苏公网安备 32020602001023号</span>
          </a>
        </span>
      
    
  </div>


  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/img-lazyload.js" ></script>
  



  



  <script  src="https://cdn.jsdelivr.net/npm/tocbot@4.12.2/dist/tocbot.min.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4.3.0/anchor.min.js" ></script>



  <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js" ></script>




  <script defer src="/js/leancloud.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
      typing(title)
      
    })(window, document);
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    (function () {
      var path = "/local-search.xml";
      $('#local-search-input').on('click', function() {
        searchFunc(path, 'local-search-input', 'local-search-result');
      });
      $('#modalSearch').on('shown.bs.modal', function() {
        $('#local-search-input').focus();
      });
    })()
  </script>





  

  
    <!-- MathJax -->
    <script>
      MathJax = {
        tex: {
          inlineMath: [['$', '$'], ['\\(', '\\)']]
        },
        options: {
          renderActions: {
            findScript: [10, doc => {
              document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
                const display = !!node.type.match(/; *mode=display/);
                const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
                const text = document.createTextNode('');
                node.parentNode.replaceChild(text, node);
                math.start = { node: text, delim: '', n: 0 };
                math.end = { node: text, delim: '', n: 0 };
                doc.math.push(math);
              });
            }, '', false],
            insertedScript: [200, () => {
              document.querySelectorAll('mjx-container').forEach(node => {
                let target = node.parentNode;
                if (target.nodeName.toLowerCase() === 'li') {
                  target.parentNode.classList.add('has-jax');
                }
              });
            }, '', false]
          }
        }
      };
    </script>

    <script async src="https://cdn.jsdelivr.net/npm/mathjax@3.1.2/es5/tex-svg.js" ></script>

  








  
    <!-- Baidu Analytics -->
    <script defer>
      var _hmt = _hmt || [];
      (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?608f2baddd361128381ad2bf9377bf89";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
  

  

  

  

  

  





<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>


</body>
</html>
